﻿@{
    ViewBag.Title = "Create Form";
}
<link href="~/Assets/css/jquery-ui-1.10.3.custom.min.css" rel="stylesheet" />
<link href="~/Assets/css/tagmanager.css" rel="stylesheet" />
<link href="~/Assets/css/typeahead.css" rel="stylesheet" />
<script src="~/Assets/js/jquery.form.js"></script>
<script src="~/assets/js/jquery.validate.min.js"></script>
<script src="~/Assets/js/typeahead.bundle.js"></script>
<script src="~/Assets/js/flexflow-controls.js"></script>
<script src="~/Assets/js/tagmanager.js"></script>
<script src="~/Assets/js/handlebars.js"></script>
<style>
    /*修复typeahead的预选提示文本框的样式*/
    input.tm-input-typeahead[readonly] {
        cursor: default;
        background: #ffffff none repeat scroll 0% 0% !important;
    }
</style>

<div class="row">
    <form class="form-horizontal" role="form" id="frmCreateInfo">
        <div class="form-group">
            <label class="col-sm-3 control-label no-padding-right" for="name"> 名称 </label>
            <div class="col-sm-9">
                <input type="text" id="name" name="name" placeholder="名称" class="col-xs-12 col-sm-9">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label no-padding-right" for="name"> 表单模板 </label>
            <div class="col-sm-9">
                <input type="text" id="tempSelector" name="tempSelector" placeholder="表单模板" style="width:9em;" autocomplete="off" class="input-medium tm-input tm-input-success tm-input-typeahead" />
            </div>
        </div>
        <div class="col-md-offset-3 col-md-9">
            <button class="btn btn-info" type="submit">
                <i class="icon-ok bigger-110"></i>
                提交
            </button>

            &nbsp; &nbsp; &nbsp;
            <button class="btn" type="reset">
                <i class="icon-undo bigger-110"></i>
                重设
            </button>
        </div>
    </form>
    <script>
        function doCreateForm() {
            $("#frmCreateInfo").ajaxSubmit({
                type: "POST",
                url: "/FormAPI/Create",
                success: function (response, statusText) {
                    table.ajax.reload().draw(false);
                    bootbox.dialog({
                        message: response.Message,
                        buttons: {
                            "success": {
                                "label": "确定",
                                "className": "btn-sm btn-primary"
                            }
                        }
                    });
                }
            })
        }
        function initForm() {
            initFormTemplateList("#tempSelector", null, {
                hiddenTagListName: "templateId",
                maxTags: 1
            });
        }
        $('#frmCreateInfo').validate(buildOpt(doCreateForm, function () { }));
        initForm();
    </script>
</div>
